package com.business_clean.viewmodel.request

import androidx.lifecycle.MutableLiveData
import com.business_clean.app.config.Constant.PAGE_SIZE
import com.business_clean.app.network.NetUrl
import com.business_clean.data.mode.BaseDownLoadEntity
import com.business_clean.data.mode.roster.RosterEntity
import me.hgj.mvvmhelper.base.BaseViewModel
import me.hgj.mvvmhelper.ext.rxHttpRequest
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse

class RosterViewModel : BaseViewModel() {

    var rosterManager = MutableLiveData<RosterEntity>()


    var downLoadEntity = MutableLiveData<BaseDownLoadEntity>()

    //获取花名册列表
    fun getRosterList(hashMap: HashMap<String, String>) {
        rxHttpRequest {
            onRequest = {
                rosterManager.value = RxHttp.get(NetUrl.GET_ROSTER_PERSON_LIST)
                    .addAll(hashMap)
                    .toResponse<RosterEntity>().await()
            }
        }
    }


    /**
     * 操作类型 user档案 roster花名册 month_attendance月度考勤
     * 导出 excel
     */
    fun requestDownloadExcel(status: String, is_head_office: String, project_uuid: String) {
        rxHttpRequest {
            onRequest = {
                downLoadEntity.value = RxHttp.get(NetUrl.DOWNLOAD_EXPORT_EXCEL)
                    .add("op_type", "roster")
                    .add("status", status)
                    .add("is_head_office", is_head_office)
                    .add("project_uuid", project_uuid)
                    .toResponse<BaseDownLoadEntity>().await()
            }
        }
    }
}